/*
 * anima/atomic.hh - Export of atomic types into main namespace.
 * Copyright (C) 2007  Mikhail Vorozhtsov
 * See the LICENSE section of the README file for details.
 */

/* $Id$ */

#ifndef HEADER_ANIMA_ATOMIC_HH
#define HEADER_ANIMA_ATOMIC_HH

#include ANIMA_ARCH_HEADER (atomic.hh)

START_NAMESPACE2 (anima,__ARCH__)

template <typename T>
struct atomic_t
{
private:
  atomic_t<typename int_t<sizeof (T) * 8>::unsigned_type_t> value;

public:
  INLINE
  atomic_t ()
  {
  }

  INLINE
  atomic_t (T x) : value ((typename int_t<sizeof (T) * 8>::unsigned_type_t) x)
  {
  }

public:
  INLINE
  T
  get ()
  {
    return (T) value.get ();
  }

  INLINE
  T
  set (T x)
  {
    return (T) value.set ((typename int_t<sizeof (T) * 8>::unsigned_type_t) x);
  }
};

END_NAMESPACE2

START_NAMESPACE (anima)

using ANIMA_ARCH::atomic_t;

typedef ANIMA_ARCH::atomic_t<u8_t> atomic8_t;
typedef ANIMA_ARCH::atomic_t<u16_t> atomic16_t;
typedef ANIMA_ARCH::atomic_t<u32_t> atomic32_t;
typedef ANIMA_ARCH::atomic_t<u64_t> atomic64_t;

END_NAMESPACE

#endif /* HEADER_ANIMA_ATOMIC_HH */

